package ebcs.scan.controller.backManagerCtr;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.log4j.Logger;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFFont;
import org.apache.poi.hssf.usermodel.HSSFRichTextString;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.ss.util.RegionUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import ebcs.database.bean.BsGroupInfor;
import ebcs.database.bean.BsProTeamInfor;
import ebcs.database.bean.BsUserDetailInfo;
import ebcs.database.bean.BsUserInfor;
import ebcs.database.bean.RpCaptalReportBean;
import ebcs.database.bean.RpPreDictionBean;
import ebcs.database.bean.RpProjectMoneyBean;
import ebcs.database.bean.RpUserReportBean;
import ebcs.database.bean.SysUserFunc;
import ebcs.database.service.BsGroupInforServiceImp;
import ebcs.database.service.BsProTeamServiceImp;
import ebcs.database.service.BsUserNeedServiceImp;
import ebcs.database.service.ReportServiceImp;
import ebcs.database.service.SystemServiceImp;
import ebcs.database.service.impl.BsProTeamServiceImpl;
import ebcs.database.service.impl.BsUserNeedServiceImpl;
import ebcs.database.service.impl.ReportServiceImpl;
import ebcs.scan.bean.common.ExcleEntity;
import ebcs.scan.common.consts.UserStatus;
import ebcs.scan.common.utils.ExportDataUtil;
import ebcs.scan.common.utils.StringUtil;
import ebcs.scan.service.wechat.WeChatTemplPushService;
import ebcs.scan.service.wechat.WechatSignTools;
import jplat.core.trans.JAppBaseService;
import jplat.core.trans.JAppContext;
import jplat.core.trans.JAppContextFactory;
import jplat.error.exception.JSystemException;
import jplat.error.exception.JTransException;
import jplat.tools.config.JAppConfig;
import jplat.tools.config.JBusConfig;
import jplat.tools.string.DateUtil;

/***
 * 报表管理
 * 
 * @author chenzhuo
 * @comment
 */
@Controller
public class ReportManagerCtrl extends JAppBaseService {
	private Logger logger = Logger.getLogger(ReportManagerCtrl.class);

	protected JAppContextFactory serviceFactory = new JAppContextFactory();

	// 数据库库服务.
	@Autowired
	public BsProTeamServiceImp teamService;
	@Autowired
	public BsGroupInforServiceImp groupService;
	@Autowired
	public BsUserNeedServiceImp userNeedService;
	@Autowired
	public ReportServiceImp reportService;
	@Autowired
	public SystemServiceImp systemService;
	@Autowired
	private WeChatTemplPushService weChatTemplPushService;
	public static String CHARSET_ENCODING = "UTF-8";
	RpProjectMoneyBean dzwList=null;
	/**
	 * 登录
	 */
	@RequestMapping("/page/main/manager.do")
	public String doIndex(HttpServletRequest request, HttpServletResponse response)
			throws JTransException, JSystemException {
		String state = request.getParameter("state");
		if(state == null || "".equals(state)){
			return "main/index";
		}
		request.getSession().setAttribute("loginUser", null);
		return "redirect:/page/main/manager.do";
	}
	/**
	 * 报表查询页面
	 */
	@RequestMapping("/page/sys/{reportId}/report.do")
	public String report(HttpServletRequest request, HttpServletResponse response, HttpSession session,@PathVariable String reportId)
			throws JTransException, JSystemException {
		//List<BsProTeamInfor> teanList = teamService.searchProTeanList();
		//List<BsGroupInfor> groupList = this.groupService.searchGroupList();
		
		Object list =  session.getAttribute("loginGroupInfo");
		//当session中没有登录用户的团队经理信息那么就跳转到登录页面
		if(list == null || "".equals(list)){
			return "main/mainLogin";
		}
		List<BsGroupInfor> bsGroupInfors = (List<BsGroupInfor>) list;
		if(bsGroupInfors.size() <= 0){
			return "main/mainLogin";
		}
		//根据团队经理信息查询出该团队经理下面所有的项目组信息
		String proGroupNo = bsGroupInfors.get(0).getProGroupNo();
		//如果是公共团队的话就可以查询出所有的团队
		if(proGroupNo != null && "10906".equals(proGroupNo)){
			List<BsProTeamInfor> teanList = teamService.searchProTeanList();
			List<BsGroupInfor> groupList = this.groupService.searchGroupList();
			request.setAttribute("teanList", teanList);
			request.setAttribute("groupList", groupList);
		}else{
			List<BsProTeamInfor> teanList = this.teamService.searchProTeanListByGroupNo(proGroupNo);
			request.setAttribute("teanList", teanList);
			request.setAttribute("groupList", list);
		}
		request.setAttribute("sysdate", DateUtil.getSystemTimeBySomeFormat("yyyyMMdd"));
		return "main/report/report" + reportId;
	}

	/**
	 * 查询产能排行榜
	 */
	@RequestMapping("/page/sys/{proTeamNo}/selectCapacityRankingList.do")
	public String selectCapacityRankingList(HttpServletRequest request, HttpServletResponse response,
			@PathVariable String proTeamNo) throws JTransException, JSystemException {
		RpUserReportBean condition = new RpUserReportBean();
		condition.setProTeamNo(proTeamNo);
		List<RpUserReportBean> rpList = this.reportService.selectCapacityRankingList(condition);
		request.setAttribute("rpList", rpList);
		return "main/report/reportCap";

	}

	/**
	 * 查询用户产能排行榜
	 */
	@RequestMapping("/page/sys/selectUserCapacityRankingList.do")
	public String selectUserCapacityRankingList(HttpServletRequest request, HttpServletResponse response)
			throws JTransException, JSystemException {
		JAppContext context = serviceFactory.buildAppContextWithUser(request, response);// 自动客户信息
		BsUserInfor user = context.getUserInfo();

		List<SysUserFunc> userFunList = this.systemService.selectUserFunction(user);
		RpUserReportBean condition = new RpUserReportBean();
		if (userFunList.size() > 0) {
			condition.setProGroupNo(user.getProGroupNo());
		} else {
			condition.setProTeamNo(user.getProTeamNo());
		}
		List<RpUserReportBean> rpList = this.reportService.selectCapacityRankingList(condition);
		request.setAttribute("rpList", rpList);
		return "main/report/reportCap";

	}

	/**
	 * 根据团队编号查询项目组列表
	 */
	@RequestMapping("/page/main/doExcelFile.do")
	public void doExcelFile(HttpServletRequest request, HttpServletResponse response)
			throws JTransException, JSystemException {
		JAppContext context = serviceFactory.buildAppContextNoUser(request, response);// 自动客户信息
		RpUserReportBean param = context.obtainReqModel(RpUserReportBean.class);
		RpUserReportBean record = new RpUserReportBean();
		record.setProGroupNo(param.getProGroupNo());
		record.setProTeamNo(param.getProTeamNo());
		record.setStartDate(param.getStartDate());
		record.setEndDate(param.getEndDate());
		record.setReportType(param.getReportType());
		List<RpUserReportBean> rsList = userNeedService.searchUserNeedInfor(record);

		String path = request.getServletContext().getRealPath("");// 获取项目动态绝对路径
		ExportDataUtil export = new ExportDataUtil();
		ExcleEntity entity = new ExcleEntity();
		entity.setTitle("未报工信息列表");
		entity.setFileName("noTask" + DateUtil.getSystemTimeBySomeFormat(DateUtil.FMT_ALL) + ".xls");
		entity.setPath(path);
		Map<Object, String> headMap = new LinkedHashMap<Object, String>();
		headMap.put("proGroupName", "团队名称");
		headMap.put("proTeamName", "项目组名称");
		headMap.put("userName", "姓名");
		headMap.put("happenDate", "异常日期");
		headMap.put("needUseTime", "填报消耗时间(小时)");
		entity.setHeadMap(headMap);
		export.exportExcel(entity, rsList);
		context.buildAppResponse(entity);
	}

	/**
	 * 根据团队编号查询项目组列表
	 */
	@RequestMapping("/page/main/{groupNo}/searchTeamList.do")
	public void searchTeamList(HttpServletRequest request, HttpServletResponse response, @PathVariable String groupNo)
			throws JTransException, JSystemException {
		JAppContext context = serviceFactory.buildAppContextNoUser(request, response);// 自动客户信息
		List<BsProTeamInfor> teanList = this.teamService.searchProTeanListByGroupNo(groupNo);
		Map rsModel = new HashMap();
		rsModel.put("teanList", teanList);
		context.buildAppResponse(rsModel);
	}

	/**
	 * 报工情况统计
	 */
	@RequestMapping("/page/main/selectHavingTaskInfor.do")
	public void reportCount(HttpServletRequest request, HttpServletResponse response)
			throws JTransException, JSystemException {
		JAppContext context = serviceFactory.buildAppContextNoUser(request, response);// 自动客户信息
		RpUserReportBean param = context.obtainReqModel(RpUserReportBean.class);

		List<RpUserReportBean> rsList = reportService.selectHavingTaskInfor(param);
		context.buildAppResponse(rsList);
	}

	/**
	 * 未报工情况统计
	 */
	@RequestMapping("/page/main/reportNoTask.do")
	public void reportNoTask(HttpServletRequest request, HttpServletResponse response)
			throws JTransException, JSystemException {
		JAppContext context = serviceFactory.buildAppContextNoUser(request, response);// 自动客户信息
		RpUserReportBean param = context.obtainReqModel(RpUserReportBean.class);
		RpUserReportBean record = new RpUserReportBean();
		record.setProGroupNo(param.getProGroupNo());
		record.setProTeamNo(param.getProTeamNo());
		record.setStartDate(param.getStartDate());
		record.setEndDate(param.getEndDate());
		record.setReportType(param.getReportType());
		List<RpUserReportBean> rsList = userNeedService.searchUserNeedInfor(record);
		context.buildAppResponse(rsList);
	}

	/**
	 * 需求预期报表统计【查下】
	 */
	@RequestMapping("/page/main/needPreDiction.do")
	public void needPreDiction(HttpServletRequest request, HttpServletResponse response)
			throws JTransException, JSystemException {
		JAppContext context = serviceFactory.buildAppContextNoUser(request, response);// 自动客户信息
		RpUserReportBean param = context.obtainReqModel(RpUserReportBean.class);
		RpUserReportBean record = new RpUserReportBean();
		record.setProGroupNo(param.getProGroupNo());
		record.setProTeamNo(param.getProTeamNo());
		record.setNeedNo(param.getNeedNo());
		record.setNeedName(param.getNeedName());
		record.setStage(param.getStage());
		List<RpPreDictionBean> rsList = this.reportService.selectPreDictionList(record);
		context.buildAppResponse(rsList);
	}
	
	/**
	 * 已报功情况统计【导出】
	 */
	@RequestMapping("/page/main/doReportCountExcelFile.do")
	public void doReportCountExcelFile(HttpServletRequest request, HttpServletResponse response)
			throws JTransException, JSystemException {
		JAppContext context = serviceFactory.buildAppContextNoUser(request, response);// 自动客户信息
		RpUserReportBean param = context.obtainReqModel(RpUserReportBean.class);

		List<RpUserReportBean> rsList = reportService.selectHavingTaskInfor(param);
		String path = request.getServletContext().getRealPath("");// 获取项目动态绝对路径
		ExportDataUtil export = new ExportDataUtil();
		ExcleEntity entity = new ExcleEntity();
		entity.setTitle("已报功情况统计");
		entity.setFileName(DateUtil.getSystemTimeBySomeFormat(DateUtil.FMT_ALL) + ".xls");
		entity.setPath(path);
		Map<Object, String> headMap = new LinkedHashMap<Object, String>();
		headMap.put("proGroupName","团队名称");
		headMap.put("proTeamName","项目组");
		headMap.put("userName","参与人员");
		headMap.put("needNo","需求编号");
		headMap.put("needName","需求名称");
		headMap.put("needUseTime","消耗工时");
		headMap.put("stage","状态");
		headMap.put("happenDate","登记时间");
		headMap.put("remark","备注");
		entity.setHeadMap(headMap);
		export.exportExcel(entity, rsList);
		context.buildAppResponse(entity);
	}
	
	/**
	 * 需求预期报表统计【导出】
	 */
	@RequestMapping("/page/main/doPreDictionExcelFile.do")
	public void doPreDictionExcelFile(HttpServletRequest request, HttpServletResponse response)
			throws JTransException, JSystemException {
		JAppContext context = serviceFactory.buildAppContextNoUser(request, response);// 自动客户信息
		RpUserReportBean param = context.obtainReqModel(RpUserReportBean.class);
		RpUserReportBean record = new RpUserReportBean();
		record.setProGroupNo(param.getProGroupNo());
		record.setProTeamNo(param.getProTeamNo());
		record.setNeedNo(param.getNeedNo());
		record.setNeedName(param.getNeedName());
		record.setStage(param.getStage());
		List<RpPreDictionBean> rsList = this.reportService.selectPreDictionList(record);

		String path = request.getServletContext().getRealPath("");// 获取项目动态绝对路径
		ExportDataUtil export = new ExportDataUtil();
		ExcleEntity entity = new ExcleEntity();
		entity.setTitle("需求预期报表统计");
		entity.setFileName(DateUtil.getSystemTimeBySomeFormat(DateUtil.FMT_ALL) + ".xls");
		entity.setPath(path);
		Map<Object, String> headMap = new LinkedHashMap<Object, String>();
		headMap.put("proGroupName", "团队名称");
		headMap.put("proTeamName", "项目名称");
		headMap.put("needNo", "需求编号");
		headMap.put("needName", "需求名称");
		headMap.put("userName", "参与人员");
		headMap.put("endWorkDate", "最新报工日期");
		headMap.put("needTime", "需求评估人月");
		headMap.put("baseNeedTime", "成本控制人月");
		headMap.put("needUseTime", "需求消耗人月");
		headMap.put("stage", "最新需求阶段");
		headMap.put("state", "需求状态");
		headMap.put("ycqk", "预测完成时间");
		headMap.put("ycbl", "预测完成比例");
		entity.setHeadMap(headMap);
		export.exportExcel(entity, rsList);
		context.buildAppResponse(entity);
	}

	/**
	 * 项目组团队产能报表
	 */
	@RequestMapping("/page/main/selectCapReportList.do")
	public void selectCapReportList(HttpServletRequest request, HttpServletResponse response)
			throws JTransException, JSystemException {
		JAppContext context = serviceFactory.buildAppContextNoUser(request, response);// 自动客户信息
		RpUserReportBean param = context.obtainReqModel(RpUserReportBean.class);
		RpUserReportBean record = new RpUserReportBean();
		record.setProGroupNo(param.getProGroupNo());
		record.setProTeamNo(param.getProTeamNo());
		List<RpCaptalReportBean> rsList = this.reportService.selectCapReportList(record);
		context.buildAppResponse(rsList);
	}

	/**
	 * 需求进度实时分析
	 */
	@RequestMapping("/page/main/cycReport.do")
	public void cycReport(HttpServletRequest request, HttpServletResponse response)
			throws JTransException, JSystemException {
		JAppContext context = serviceFactory.buildAppContextNoUser(request, response);// 自动客户信息
		RpUserReportBean record = new RpUserReportBean();

		List<RpUserReportBean> rsList = userNeedService.selectReportCount(record);
		context.buildAppResponse(rsList);
	}

	/**
	 * 人员单产实时分析
	 */
	@RequestMapping("/page/main/reportPerson.do")
	public void reportPerson(HttpServletRequest request, HttpServletResponse response)
			throws JTransException, JSystemException {
		JAppContext context = serviceFactory.buildAppContextWithUser(request, response);// 自动客户信息
		BsUserInfor custModel = context.getUserInfo();
	}

	/**
	 * 发送出勤率大于60%表格给团队经理
	 * 
	 * @return
	 * @throws JSystemException
	 */
	@RequestMapping("/page/main/reportLtSixty")
	public String reportLtSixty(HttpServletRequest request, HttpServletResponse response) throws JSystemException {
		// 查询出出勤率大于60%的数据放到request中
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
		request.setAttribute("reportDate", sdf.format(new Date()));
		RpUserReportBean record = new RpUserReportBean();
		record.setProGroupNo(request.getParameter("proGroupNo"));
		List<RpPreDictionBean> rsList = this.reportService.selectCapReportLt60(record);
		request.setAttribute("rsList", rsList);
		return "main/report/report9";
	}

	/**
	 * 发送出勤率大于60%表格给团队经理
	 * 
	 * @return
	 * @throws JSystemException
	 */
	@RequestMapping("/page/main/reportAllLtSixty")
	public String reportAllLtSixty(HttpServletRequest request, HttpServletResponse response) throws JSystemException {
		// 查询出出勤率大于60%的数据放到request中
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
		request.setAttribute("reportDate", sdf.format(new Date()));
		RpUserReportBean record = new RpUserReportBean();
		List<RpPreDictionBean> rsList = this.reportService.selectCapAllReportLt60();
		request.setAttribute("rsList", rsList);
		return "main/report/report9";
	}

	/**
	 * 
	 * @param url
	 *            调用此方法的页面
	 * @return 返回微信配置的数据
	 */
	
	@RequestMapping("/page/main/wechatConfig.do")
	public void  getWechatConfig(@RequestParam (value="url")String url ,HttpServletRequest request, HttpServletResponse response)
			throws JTransException, JSystemException {
		JAppContext context = serviceFactory.buildAppContextNoUser(request, response);// 自动客户信息
		Map<String, String> ret = weChatTemplPushService.getWechatConfig(url);
		context.buildAppResponse(ret);
	}
	/**
	 * 项目奖金分析计算查询
	 * 
	 * @param request
	 * @param response
	 * @throws JTransException
	 * @throws JSystemException
	 */
	@RequestMapping("/page/main/selectProjectMoneyList.do")
	public void selectProjectMoneyList(HttpServletRequest request, HttpServletResponse response)
			throws JTransException, JSystemException {
		JAppContext context = serviceFactory.buildAppContextNoUser(request, response);// 自动客户信息
		RpProjectMoneyBean param = context.obtainReqModel(RpProjectMoneyBean.class);
		RpProjectMoneyBean record = new RpProjectMoneyBean();
		record.setProGroupNo(param.getProGroupNo());
		record.setProTeamNo(param.getProTeamNo());
		record.setTotal(param.getTotal());
		record.setNeedName(param.getNeedName());
		record.setNeedNo(param.getNeedNo());
		record.setBgnWorkDate(param.getBgnWorkDate());
		record.setEndWorkDate(param.getEndWorkDate());
		record.setState(param.getState());
		List<RpProjectMoneyBean> rpList = reportService.selectProjectMoneyList(record);
		context.buildAppResponse(rpList);
	}
	
	/**
	 * 项目奖励表
	 * 
	 * @param request
	 * @param response
	 * @throws JTransException
	 * @throws JSystemException
	 */
	@RequestMapping("/page/main/xiangmujiangli.do")
	public void xiangmujiangli(HttpServletRequest request, HttpServletResponse response)
			throws JTransException, JSystemException {
		JAppContext context = serviceFactory.buildAppContextNoUser(request, response);// 自动客户信息
		RpProjectMoneyBean param = context.obtainReqModel(RpProjectMoneyBean.class);
		RpProjectMoneyBean record = new RpProjectMoneyBean();
		record.setProGroupNo(param.getProGroupNo());
		record.setProTeamNo(param.getProTeamNo());
		record.setTotal(param.getTotal());
		record.setNeedName(param.getNeedName());
		record.setNeedNo(param.getNeedNo());
		record.setBgnWorkDate(param.getBgnWorkDate());
		record.setEndWorkDate(param.getEndWorkDate());
		List<RpProjectMoneyBean> rpList = reportService.selectProjectMoneyList(record);
		dzwList=record;
		context.buildAppResponse(rpList);
	}

	/**
	 * 项目奖金分析计算导出
	 * 
	 * @param request
	 * @param response
	 * @throws JTransException
	 * @throws JSystemException
	 */
	@RequestMapping("/page/main/doExcelFileOfProjectMoney.do")
	public void doExcelFileOfProjectMoney(HttpServletRequest request, HttpServletResponse response)
			throws JTransException, JSystemException {
		JAppContext context = serviceFactory.buildAppContextNoUser(request, response);// 自动客户信息
		RpProjectMoneyBean param = context.obtainReqModel(RpProjectMoneyBean.class);
		RpProjectMoneyBean record = new RpProjectMoneyBean();
		record.setProGroupNo(param.getProGroupNo());
		record.setProTeamNo(param.getProTeamNo());
		record.setTotal(param.getTotal());
		record.setNeedName(param.getNeedName());
		record.setNeedNo(param.getNeedNo());
		record.setBgnWorkDate(param.getBgnWorkDate());
		record.setEndWorkDate(param.getEndWorkDate());
		record.setState(param.getState());
		List<RpProjectMoneyBean> rpList = reportService.selectProjectMoneyList(record);
		String path = request.getServletContext().getRealPath("");// 获取项目动态绝对路径
		ExportDataUtil export = new ExportDataUtil();
		ExcleEntity entity = new ExcleEntity();
		entity.setTitle("项目奖金计算分析列表");
		entity.setFileName("ProjectMoney" + DateUtil.getSystemTimeBySomeFormat(DateUtil.FMT_ALL) + ".xls");
		entity.setPath(path);
		Map<Object, String> headMap = new LinkedHashMap<Object, String>();
		headMap.put("proGroupName", "团队名称");
		headMap.put("proTeamName", "项目组");
		headMap.put("needNo", "需求编号");
		headMap.put("needName", "需求名称");
		headMap.put("userName", "参与人员");
		headMap.put("needTime", "评估工时");
		headMap.put("cbkzry", "成本控制人月");
		headMap.put("needUseTime", "需求消耗人月 ");
		headMap.put("rydc", "人员单产(万元)");
		headMap.put("bgnWorkDate", "开始报工日期");
		headMap.put("endWorkDate", "最新报工日期");
		headMap.put("stage", "最新需求阶段");
		headMap.put("state", "需求状态");
		headMap.put("ycqk", "分析结果");
		headMap.put("ycbl", "需求消耗/需求评估");
		headMap.put("dcfz", "单产分值");
		headMap.put("needUserBl", "人员结构比值");
		headMap.put("needuserscore", "人员结构比值得分");
		headMap.put("grade", "甲方评分");
		headMap.put("total", "总分值");
		entity.setHeadMap(headMap);
		export.exportExcel(entity, rpList);
		context.buildAppResponse(entity);
	}

	/**
	 * 根据needId查询项目奖金分析计算二级信息
	 * 
	 * @param request
	 * @param response
	 * @param userNo
	 * @return
	 * @throws JTransException
	 * @throws JSystemException
	 */
	@RequestMapping("/page/main/{needId}/searchDetailByNeedId.do")
	public String searchDetailByNeedId(HttpServletRequest request, HttpServletResponse response,
			@PathVariable String needId) throws JTransException, JSystemException {
		List<RpProjectMoneyBean> detailInfoList = reportService.searchDetailByNeedId(needId);
		request.setAttribute("detailInfoList", detailInfoList);
		return "main/report/projectMoneyDetail";
	}
	/**
	 * 根据needId和userNO查询项目奖金分析计算三级信息
	 * 
	 * @param request
	 * @param response
	 * @param userNo
	 * @return
	 * @throws JTransException
	 * @throws JSystemException
	 */
	@RequestMapping("/page/main/{needId}/searchByNeedIdAndUserNo.do")
	public String searchByNeedIdAndUserNo(HttpServletRequest request, HttpServletResponse response,
			@PathVariable String needId,@RequestParam  String userNo) throws JTransException, JSystemException {
		RpUserReportBean record = new  RpUserReportBean();
		record.setUserNo(userNo);
		record.setRouid(needId);
		List<RpUserReportBean> rsList = userNeedService.searchUserHistoryNeedInfor(record);
		if(rsList!=null&&rsList.size()>0){
			request.setAttribute("userName", rsList.get(0).getUserName());
			request.setAttribute("proTeamName", rsList.get(0).getProTeamName());
			request.setAttribute("proGroupName", rsList.get(0).getProGroupName());
		}
 		request.setAttribute("detailInfoList", rsList);
		return "main/report/projectMoneyDetail2";
	}
    //合并对话框加边框	
	private static void setBorderForMergeCell(int i,CellRangeAddress cellRange,HSSFSheet sheet,HSSFWorkbook wb){
    	RegionUtil.setBorderBottom(i, cellRange, sheet, wb);
    	RegionUtil.setBorderLeft(i, cellRange, sheet, wb);
    	RegionUtil.setBorderRight(i, cellRange, sheet, wb);
    	RegionUtil.setBorderTop(i, cellRange, sheet, wb);
    }
	@RequestMapping("/page/main/load.do")
	public void loadexecl(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    	request.setCharacterEncoding("UTF-8");
    	response.setCharacterEncoding("UTF-8");
    	response.setContentType("text/html;UTF-8");
    	HSSFWorkbook wb=new HSSFWorkbook();
    	
    	HSSFSheet sheet=wb.createSheet("项目毛利");
    	HSSFSheet sheet1=wb.createSheet("评估表");
    	HSSFSheet sheet2=wb.createSheet("项目奖励");
    	
    	HSSFFont font=wb.createFont();
    	font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
    	font.setFontHeightInPoints((short)16);
    	HSSFFont font1=wb.createFont();
    	font1.setFontName("微软雅黑");
    	font1.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
    	font1.setFontHeightInPoints((short)10);
    	
    	HSSFCellStyle style=wb.createCellStyle();
    	style.setFont(font);
    	style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
    	style.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
    	style.setBorderBottom(HSSFCellStyle.BORDER_THIN);
    	style.setBorderLeft(HSSFCellStyle.BORDER_THIN);
    	style.setBorderRight(HSSFCellStyle.BORDER_THIN);
    	style.setBorderTop(HSSFCellStyle.BORDER_THIN);
    	
    	HSSFCellStyle style1=wb.createCellStyle();
    	style1.setFont(font1);
    	style1.setAlignment(HSSFCellStyle.ALIGN_CENTER);
    	style1.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
    	style1.setBorderBottom(HSSFCellStyle.BORDER_THIN);
    	style1.setBorderLeft(HSSFCellStyle.BORDER_THIN);
    	style1.setBorderRight(HSSFCellStyle.BORDER_THIN);
    	style1.setBorderTop(HSSFCellStyle.BORDER_THIN);
    	
    	HSSFCellStyle style2=wb.createCellStyle();
    	style2.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
    	style2.setFillForegroundColor((short)26);
    	style2.setFont(font1);
    	style2.setAlignment(HSSFCellStyle.ALIGN_CENTER);
    	style2.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
    	style2.setBorderBottom(HSSFCellStyle.BORDER_THIN);
    	style2.setBorderLeft(HSSFCellStyle.BORDER_THIN);
    	style2.setBorderRight(HSSFCellStyle.BORDER_THIN);
    	style2.setBorderTop(HSSFCellStyle.BORDER_THIN);
    	
    	HSSFCellStyle style3=wb.createCellStyle();
    	style3.setAlignment(HSSFCellStyle.ALIGN_CENTER);
    	style3.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
    	style3.setBorderBottom(HSSFCellStyle.BORDER_THIN);
    	style3.setBorderLeft(HSSFCellStyle.BORDER_THIN);
    	style3.setBorderRight(HSSFCellStyle.BORDER_THIN);
    	style3.setBorderTop(HSSFCellStyle.BORDER_THIN);
    	
    	/*sheet.setDefaultColumnWidth(3000);
    	sheet.setColumnWidth(0, 6000);
    	sheet.setColumnWidth(1, 4000);
    	sheet.setColumnWidth(3, 3500);*/
    	sheet.setDefaultRowHeight((short)600);
    	
    	HSSFRow row=sheet.createRow(0);
    	
    	HSSFCell c0=row.createCell(0);
    	for(int i=0;i<=11;i++)
    		row.createCell(i);
    	c0.setCellValue(new HSSFRichTextString(reportService.selectProjectMoneyList(dzwList).get(0).getProGroupName()+"团队"+dzwList.getBgnWorkDate().substring(0, 6)+"-"+dzwList.getEndWorkDate().substring(0,6)+"奖励明细表"));
    	c0.setCellStyle(style);
    	HSSFCell c1=row.createCell(10);
    	c1.setCellStyle(style3);
    	c1.setCellValue(new HSSFRichTextString("单位：万元"));
    	
    	HSSFRow row1=sheet.createRow(1);
    	HSSFCell c10=row1.createCell(0);
    	c10.setCellValue(new HSSFRichTextString("软件部填"));
    	c10.setCellStyle(style2);
    	HSSFCell c11=row1.createCell(1);
    	c11.setCellValue(new HSSFRichTextString("软件部填"));
    	c11.setCellStyle(style2);
    	HSSFCell c12=row1.createCell(2);
    	c12.setCellValue(new HSSFRichTextString("软件部填"));
    	c12.setCellStyle(style2);
    	HSSFCell c13=row1.createCell(3);
    	c13.setCellValue(new HSSFRichTextString("财务部核对"));
    	c13.setCellStyle(style2);
    	HSSFCell c14=row1.createCell(4);
    	c14.setCellValue(new HSSFRichTextString("财务部填"));
    	c14.setCellStyle(style2);
    	HSSFCell c15=row1.createCell(5);
    	c15.setCellValue(new HSSFRichTextString("人力资源填"));
    	c15.setCellStyle(style2);
    	HSSFCell c16=row1.createCell(6);
    	c16.setCellValue(new HSSFRichTextString("财务部填"));
    	c16.setCellStyle(style2);
    	HSSFCell c17=row1.createCell(8);
    	c17.setCellValue(new HSSFRichTextString("财务部填"));
    	c17.setCellStyle(style2);
    	HSSFCell c18=row1.createCell(9);
    	c18.setCellValue(new HSSFRichTextString("人力资源填"));
    	c18.setCellStyle(style2);
    	HSSFCell c19=row1.createCell(10);
    	c19.setCellValue(new HSSFRichTextString("财务部填"));
    	c19.setCellStyle(style2);
    	
    	HSSFRow row2=sheet.createRow(2);
    	HSSFCell c20=row2.createCell(0);
    	c20.setCellValue(new HSSFRichTextString("项目名称"));
    	c20.setCellStyle(style1);
    	HSSFCell c21=row2.createCell(1);
    	c21.setCellValue(new HSSFRichTextString("需求明细"));
    	c21.setCellStyle(style1);
    	HSSFCell c22=row2.createCell(2);
    	c22.setCellValue(new HSSFRichTextString("项目金额"));
    	c22.setCellStyle(style1);
    	HSSFCell c23=row2.createCell(3);
    	c23.setCellValue(new HSSFRichTextString("系统核定金额"));
    	c23.setCellStyle(style1);
    	HSSFCell c24=row2.createCell(4);
    	c24.setCellValue(new HSSFRichTextString("税金"));
    	c24.setCellStyle(style1);
    	HSSFCell c25=row2.createCell(5);
    	c25.setCellValue(new HSSFRichTextString("人力成本"));
    	c25.setCellStyle(style1);
    	HSSFCell c26=row2.createCell(6);
    	c26.setCellValue(new HSSFRichTextString("项目费用"));
    	c26.setCellStyle(style1);
    	HSSFCell c27=row2.createCell(7);
    	c27.setCellValue(new HSSFRichTextString("项目毛利"));
    	c27.setCellStyle(style1);
    	HSSFCell c28=row2.createCell(8);
    	c28.setCellValue(new HSSFRichTextString("总指标"));
    	c28.setCellStyle(style1);
    	
    	HSSFRow row3=sheet.createRow(3);
    	HSSFCell c30=row3.createCell(8);
    	c30.setCellValue(new HSSFRichTextString("团队总收入"));
    	c30.setCellStyle(style1);
    	HSSFCell c31=row3.createCell(9);
    	c31.setCellValue(new HSSFRichTextString("团队总人数"));
    	c31.setCellStyle(style1);
    	HSSFCell c32=row3.createCell(10);
    	c32.setCellValue(new HSSFRichTextString("人均产值"));
    	c32.setCellStyle(style1);
    	HSSFCell c33=row3.createCell(11);
    	c33.setCellValue(new HSSFRichTextString("人力成本"));
    	c33.setCellStyle(style1);
    	
    	
    	HSSFRow row4;
    	List<RpProjectMoneyBean> dzw = reportService.selectProjectMoneyList(dzwList);
    	/*for(int i=0;i<dzw.size();i++){
    		row4=sheet.createRow((int)i+4);
    		DAIZHIWEI list=dzw.get(i);
    		row4.createCell(0).setCellValue(list.getPHONE());
    		row4.createCell(1).setCellValue(list.getNAME());
    	}*/
    	int y=0;
    	int num=dzw.size();
    	int k=4;
    	double Tmony=0;
    	while(!dzw.isEmpty()){
    		row4=sheet.createRow(num-dzw.size()+k);
    		int x=num-dzw.size()+k;
    		y=0;
    		HSSFCell cc1=row4.createCell(0);
    		cc1.setCellStyle(style3);
    		cc1.setCellValue(dzw.get(0).getProTeamName());
    		RpProjectMoneyBean list=dzw.get(0);
    		double Tmony1=0;
    		for(int i=0;i<dzw.size();){
    			if((list.getProTeamName()).equals(dzw.get(0).getProTeamName()))
    			{
    				cc1=row4.createCell(1);
    				cc1.setCellStyle(style3);
    				cc1.setCellValue(dzw.get(i).getNeedNo());
    				cc1=row4.createCell(2);
    				cc1.setCellStyle(style3);
    				String str=dzw.get(i).getNeedUseTime();
    				cc1.setCellValue(Double.parseDouble(str)*2.5);
    				Tmony1+=Double.parseDouble(str)*2.5;
    				for(int j=2;j<=7;j++)
    	    			setBorderForMergeCell(HSSFCellStyle.BORDER_THIN,new CellRangeAddress(num-dzw.size()+k,num-dzw.size()+k,j,j),sheet,wb);
    				dzw.remove(i);    	
    				row4=sheet.createRow(num-dzw.size()+k);
    			}
    			else i++;
    		}
    		Tmony+=Tmony1;
    		for(int j=2;j<=11;j++)
    			setBorderForMergeCell(HSSFCellStyle.BORDER_THIN,new CellRangeAddress(num-dzw.size()+k,num-dzw.size()+k,j,j),sheet,wb);
    		k++;
    		cc1=row4.createCell(1);
    		cc1.setCellStyle(style3);
    		cc1.setCellValue("合计");
    		cc1=row4.createCell(2);
    		cc1.setCellStyle(style3);
    		cc1.setCellValue(Tmony1);
    		y=num-dzw.size()+k-1;
    		sheet.addMergedRegion(new CellRangeAddress(x,y,0,0));
    		setBorderForMergeCell(HSSFCellStyle.BORDER_THIN,new CellRangeAddress(x,y,0,0),sheet,wb);
    		sheet.addMergedRegion(new CellRangeAddress(x,y-1,11,11));
    		setBorderForMergeCell(HSSFCellStyle.BORDER_THIN,new CellRangeAddress(x,y-1,11,11),sheet,wb);
    		sheet.addMergedRegion(new CellRangeAddress(x,y-1,10,10));
    		setBorderForMergeCell(HSSFCellStyle.BORDER_THIN,new CellRangeAddress(x,y-1,10,10),sheet,wb);
    		sheet.addMergedRegion(new CellRangeAddress(x,y-1,9,9));
    		setBorderForMergeCell(HSSFCellStyle.BORDER_THIN,new CellRangeAddress(x,y-1,9,9),sheet,wb);
    		sheet.addMergedRegion(new CellRangeAddress(x,y-1,8,8));
    		setBorderForMergeCell(HSSFCellStyle.BORDER_THIN,new CellRangeAddress(x,y-1,8,8),sheet,wb);
    	}
    	row4=sheet.createRow(y+1);
    	HSSFCell cc1=row4.createCell(0);
    	cc1.setCellStyle(style3);
		cc1.setCellValue("合计");
		cc1=row4.createCell(2);
    	cc1.setCellStyle(style3);
		cc1.setCellValue(Tmony);
		sheet.addMergedRegion(new CellRangeAddress(y+1,y+1,0,1));
		setBorderForMergeCell(HSSFCellStyle.BORDER_THIN,new CellRangeAddress(y+1,y+1,0,1),sheet,wb);
		for(int j=2;j<=11;j++)
			setBorderForMergeCell(HSSFCellStyle.BORDER_THIN,new CellRangeAddress(y+1,y+1,j-1,j),sheet,wb);
		
    	
    	sheet.addMergedRegion(new CellRangeAddress(0,0,0,9));
    	setBorderForMergeCell(HSSFCellStyle.BORDER_THIN,new CellRangeAddress(0,0,0,9),sheet,wb);
    	sheet.addMergedRegion(new CellRangeAddress(0,0,10,11));
    	setBorderForMergeCell(HSSFCellStyle.BORDER_THIN,new CellRangeAddress(0,0,10,11),sheet,wb);
    	sheet.addMergedRegion(new CellRangeAddress(1,1,6,7));
    	setBorderForMergeCell(HSSFCellStyle.BORDER_THIN,new CellRangeAddress(1,1,6,7),sheet,wb);
    	sheet.addMergedRegion(new CellRangeAddress(1,1,10,11));
    	setBorderForMergeCell(HSSFCellStyle.BORDER_THIN,new CellRangeAddress(1,1,10,11),sheet,wb);
    	sheet.addMergedRegion(new CellRangeAddress(2,3,0,0));
    	setBorderForMergeCell(HSSFCellStyle.BORDER_THIN,new CellRangeAddress(2,3,0,0),sheet,wb);
    	sheet.addMergedRegion(new CellRangeAddress(2,3,1,1));
    	setBorderForMergeCell(HSSFCellStyle.BORDER_THIN,new CellRangeAddress(2,3,1,1),sheet,wb);
    	sheet.addMergedRegion(new CellRangeAddress(2,3,2,2));
    	setBorderForMergeCell(HSSFCellStyle.BORDER_THIN,new CellRangeAddress(2,3,2,2),sheet,wb);
    	sheet.addMergedRegion(new CellRangeAddress(2,3,3,3));
    	setBorderForMergeCell(HSSFCellStyle.BORDER_THIN,new CellRangeAddress(2,3,3,3),sheet,wb);
    	sheet.addMergedRegion(new CellRangeAddress(2,3,4,4));
    	setBorderForMergeCell(HSSFCellStyle.BORDER_THIN,new CellRangeAddress(2,3,4,4),sheet,wb);
    	sheet.addMergedRegion(new CellRangeAddress(2,3,5,5));
    	setBorderForMergeCell(HSSFCellStyle.BORDER_THIN,new CellRangeAddress(2,3,5,5),sheet,wb);
    	sheet.addMergedRegion(new CellRangeAddress(2,3,6,6));
    	setBorderForMergeCell(HSSFCellStyle.BORDER_THIN,new CellRangeAddress(2,3,6,6),sheet,wb);
    	sheet.addMergedRegion(new CellRangeAddress(2,3,7,7));
    	setBorderForMergeCell(HSSFCellStyle.BORDER_THIN,new CellRangeAddress(2,3,7,7),sheet,wb);
    	sheet.addMergedRegion(new CellRangeAddress(2,2,8,11));
    	setBorderForMergeCell(HSSFCellStyle.BORDER_THIN,new CellRangeAddress(2,2,8,11),sheet,wb);
    	
    	for(int i=0;i<=11;i++)
    	{
    		sheet.autoSizeColumn(i);
    		sheet.autoSizeColumn(i,true);
    	}
    	//sheet2
        sheet2.setDefaultRowHeight((short)600);
    	HSSFRow rows=sheet2.createRow(0);	
    	HSSFCell a0=rows.createCell(0);
    	for(int i=0;i<=5;i++)
    		rows.createCell(i);
    	a0.setCellValue(new HSSFRichTextString(reportService.selectProjectMoneyList(dzwList).get(0).getProGroupName()+"团队"+dzwList.getBgnWorkDate()+"-"+dzwList.getEndWorkDate()+"奖励表"));
    	a0.setCellStyle(style);
    	HSSFCell a1=rows.createCell(5);
    	a1.setCellStyle(style3);
    	a1.setCellValue(new HSSFRichTextString("单位：万元"));
    	
    	HSSFRow rows1=sheet2.createRow(1);
    	HSSFCell a10=rows1.createCell(0);
    	a10.setCellValue(new HSSFRichTextString("软件部填"));
    	a10.setCellStyle(style2);
    	HSSFCell a11=rows1.createCell(1);
    	a11.setCellValue(new HSSFRichTextString("软件部填"));
    	a11.setCellStyle(style2);
    	HSSFCell a12=rows1.createCell(2);
    	a12.setCellValue(new HSSFRichTextString("财务部填"));
    	a12.setCellStyle(style2);
    	
    	HSSFRow rows2=sheet2.createRow(2);
    	HSSFCell a20=rows2.createCell(0);
    	a20.setCellValue(new HSSFRichTextString("项目名称"));
    	a20.setCellStyle(style1);
    	HSSFCell a21=rows2.createCell(1);
    	a21.setCellValue(new HSSFRichTextString("需求明细"));
    	a21.setCellStyle(style1);
    	HSSFCell a22=rows2.createCell(2);
    	a22.setCellValue(new HSSFRichTextString("项目毛利"));
    	a22.setCellStyle(style1);
    	HSSFCell a23=rows2.createCell(3);
    	a23.setCellValue(new HSSFRichTextString("综合得分"));
    	a23.setCellStyle(style1);
    	HSSFCell a24=rows2.createCell(4);
    	a24.setCellValue(new HSSFRichTextString("对应奖金等级"));
    	a24.setCellStyle(style1);
    	HSSFCell a25=rows2.createCell(5);
    	a25.setCellValue(new HSSFRichTextString("奖金总额"));
    	a25.setCellStyle(style1);
    	
    	
    	HSSFRow rows4;
    	List<RpProjectMoneyBean> dzw2 = reportService.selectProjectMoneyList(dzwList);
    	/*for(int i=0;i<dzw.size();i++){
    		row4=sheet.createRow((int)i+4);
    		DAIZHIWEI list=dzw.get(i);
    		row4.createCell(0).setCellValue(list.getPHONE());
    		row4.createCell(1).setCellValue(list.getNAME());
    	}*/
    	int y2=0;
    	int num2=dzw2.size();
    	int k2=3;
    	while(!dzw2.isEmpty()){
    		rows4=sheet2.createRow(num2-dzw2.size()+k2);
    		int x=num2-dzw2.size()+k2;
    		y2=0;
    		HSSFCell aa1=rows4.createCell(0);
    		aa1.setCellStyle(style3);
    		aa1.setCellValue(dzw2.get(0).getProTeamName());
    		RpProjectMoneyBean list=dzw2.get(0);
    		for(int i=0;i<dzw2.size();){
    			if((list.getProTeamName()).equals(dzw2.get(i).getProTeamName()))
    			{
    				aa1=rows4.createCell(1);
    				aa1.setCellStyle(style3);
    				aa1.setCellValue(dzw2.get(i).getNeedNo());
    				for(int j=1;j<=5;j++)
    	    			setBorderForMergeCell(HSSFCellStyle.BORDER_THIN,new CellRangeAddress(num2-dzw2.size()+k2,num2-dzw2.size()+k2,j,j),sheet2,wb);
    				dzw2.remove(i);    	
    				rows4=sheet2.createRow(num2-dzw2.size()+k2);
    			}
    			else i++;
    		}
    		for(int j=2;j<=5;j++)
    			setBorderForMergeCell(HSSFCellStyle.BORDER_THIN,new CellRangeAddress(num2-dzw2.size()+k2,num2-dzw2.size()+k2,j,j),sheet2,wb);
    		k2++;
    		aa1=rows4.createCell(1);
    		aa1.setCellStyle(style3);
    		aa1.setCellValue("合计");
    		y2=num2-dzw2.size()+k2-1;
    		sheet2.addMergedRegion(new CellRangeAddress(x,y2,0,0));
    		setBorderForMergeCell(HSSFCellStyle.BORDER_THIN,new CellRangeAddress(x,y2,0,0),sheet2,wb);
    	}
    	rows4=sheet2.createRow(y2+1);
    	HSSFCell aa1=rows4.createCell(0);
    	aa1.setCellStyle(style3);
		aa1.setCellValue("合计");
		sheet2.addMergedRegion(new CellRangeAddress(y2+1,y2+1,0,1));
		setBorderForMergeCell(HSSFCellStyle.BORDER_THIN,new CellRangeAddress(y2+1,y2+1,0,1),sheet2,wb);
		for(int j=2;j<=5;j++)
			setBorderForMergeCell(HSSFCellStyle.BORDER_THIN,new CellRangeAddress(y2+1,y2+1,j-1,j),sheet2,wb);
		
		
		
		sheet2.addMergedRegion(new CellRangeAddress(0,0,5,5));
    	setBorderForMergeCell(HSSFCellStyle.BORDER_THIN,new CellRangeAddress(0,0,5,5),sheet2,wb);
		sheet2.addMergedRegion(new CellRangeAddress(0,0,0,4));
    	setBorderForMergeCell(HSSFCellStyle.BORDER_THIN,new CellRangeAddress(0,0,0,4),sheet2,wb);
    	sheet2.addMergedRegion(new CellRangeAddress(1,1,2,5));
    	setBorderForMergeCell(HSSFCellStyle.BORDER_THIN,new CellRangeAddress(1,1,2,5),sheet2,wb);
    	
    	for(int i=0;i<=11;i++)
    	{
    		sheet2.autoSizeColumn(i);
    		sheet2.autoSizeColumn(i,true);
    	}
    	//sheet1********************************************************
    	sheet1.setDefaultRowHeight((short)600);
    	HSSFRow rowd=sheet1.createRow(0);
    	HSSFCell b0=rowd.createCell(0);
    	for(int i=0;i<=10;i++)
    		rowd.createCell(i);
    	b0.setCellValue(new HSSFRichTextString(reportService.selectProjectMoneyList(dzwList).get(0).getProGroupName()+"团队"+dzwList.getBgnWorkDate()+"-"+dzwList.getEndWorkDate()+"项目评估表"));
    	b0.setCellStyle(style);
    	HSSFCell b1=rowd.createCell(9);
    	b1.setCellStyle(style3);
    	b1.setCellValue(new HSSFRichTextString("单位：万元"));
    	
    	HSSFRow rowd1=sheet1.createRow(1);
    	HSSFCell b10=rowd1.createCell(0);
    	b10.setCellValue(new HSSFRichTextString("软件部填"));
    	b10.setCellStyle(style2);
    	HSSFCell b11=rowd1.createCell(1);
    	b11.setCellValue(new HSSFRichTextString("软件部填"));
    	b11.setCellStyle(style2);
    	HSSFCell b12=rowd1.createCell(2);
    	b12.setCellValue(new HSSFRichTextString("财务部填"));
    	b12.setCellStyle(style2);
    	HSSFCell b13=rowd1.createCell(3);
    	b13.setCellValue(new HSSFRichTextString("软件部填/人力资源核对"));
    	b13.setCellStyle(style2);
    	HSSFCell b14=rowd1.createCell(6);
    	b14.setCellValue(new HSSFRichTextString("软件部填/人力资源核对"));
    	b14.setCellStyle(style2);
    	HSSFCell b15=rowd1.createCell(8);
    	b15.setCellValue(new HSSFRichTextString("软件部填/人力资源核对"));
    	b15.setCellStyle(style2);
    	HSSFCell b16=rowd1.createCell(10);
    	b16.setCellValue(new HSSFRichTextString("综合得分"));
    	b16.setCellStyle(style2);
    	
    	
    	HSSFRow rowd2=sheet1.createRow(2);
    	HSSFCell b20=rowd2.createCell(0);
    	b20.setCellValue(new HSSFRichTextString("项目名称"));
    	b20.setCellStyle(style1);
    	HSSFCell b21=rowd2.createCell(1);
    	b21.setCellValue(new HSSFRichTextString("需求明细"));
    	b21.setCellStyle(style1);
    	HSSFCell b22=rowd2.createCell(2);
    	b22.setCellValue(new HSSFRichTextString("系统核定金额"));
    	b22.setCellStyle(style1);
    	HSSFCell b23=rowd2.createCell(3);
    	b23.setCellValue(new HSSFRichTextString("需求消耗人月"));
    	b23.setCellStyle(style1);
    	HSSFCell b24=rowd2.createCell(4);
    	b24.setCellValue(new HSSFRichTextString("人均产值"));
    	b24.setCellStyle(style1);
    	HSSFCell b25=rowd2.createCell(6);
    	b25.setCellValue(new HSSFRichTextString("人员结构"));
    	b25.setCellStyle(style1);
    	HSSFCell b26=rowd2.createCell(8);
    	b26.setCellValue(new HSSFRichTextString("甲方评分"));
    	b26.setCellStyle(style1);
    	
    	
    	HSSFRow rowd3=sheet1.createRow(3);
    	HSSFCell b30=rowd3.createCell(4);
    	b30.setCellValue(new HSSFRichTextString("产值"));
    	b30.setCellStyle(style1);
    	HSSFCell b31=rowd3.createCell(5);
    	b31.setCellValue(new HSSFRichTextString("得分"));
    	b31.setCellStyle(style1);
    	HSSFCell b32=rowd3.createCell(6);
    	b32.setCellValue(new HSSFRichTextString("比例"));
    	b32.setCellStyle(style1);
    	HSSFCell b33=rowd3.createCell(7);
    	b33.setCellValue(new HSSFRichTextString("得分"));
    	b33.setCellStyle(style1);
    	HSSFCell b34=rowd3.createCell(8);
    	b34.setCellValue(new HSSFRichTextString("评分结果"));
    	b34.setCellStyle(style1);
    	HSSFCell b35=rowd3.createCell(9);
    	b35.setCellValue(new HSSFRichTextString("得分"));
    	b35.setCellStyle(style1);
    	
    	
    	HSSFRow rowd4;
    	List<RpProjectMoneyBean> dzw1 = reportService.selectProjectMoneyList(dzwList);
    	/*for(int i=0;i<dzw.size();i++){
    		row4=sheet.createRow((int)i+4);
    		DAIZHIWEI list=dzw.get(i);
    		row4.createCell(0).setCellValue(list.getPHONE());
    		row4.createCell(1).setCellValue(list.getNAME());
    	}*/
    	int y1=0;
    	int num1=dzw1.size();
    	int k1=4;
    	double Peoplemonly=0,Chanmuch=0,Scord=0,Lastsocrd=0;
    	while(!dzw1.isEmpty()){
    		rowd4=sheet1.createRow(num1-dzw1.size()+k1);
    		int x=num1-dzw1.size()+k1;
    		y1=0;
    		HSSFCell bb1=rowd4.createCell(0);
    		bb1.setCellStyle(style3);
    		bb1.setCellValue(dzw1.get(0).getProTeamName());
    		RpProjectMoneyBean list=dzw1.get(0);
    		double Peoplemonly1=0,Chanmuch1=0,Scord1=0,Lastsocrd1=0;
    		for(int i=0;i<dzw1.size();){
    			if((list.getProTeamName()).equals(dzw1.get(i).getProTeamName()))
    			{
    				bb1=rowd4.createCell(1);
    				bb1.setCellStyle(style3);
    				bb1.setCellValue(dzw1.get(i).getNeedNo());
    				
    				bb1=rowd4.createCell(3);
    				String str1=dzw1.get(i).getNeedUseTime();
    				bb1.setCellStyle(style3);
    				bb1.setCellValue(Double.parseDouble(str1));
    				Peoplemonly1+=Double.parseDouble(str1);
    				
    				bb1=rowd4.createCell(4);
    				String str2=dzw1.get(i).getRydc();
    				bb1.setCellStyle(style3);
    				bb1.setCellValue(Double.parseDouble(str2));
    				Chanmuch1+=Double.parseDouble(str2);
    				
    				bb1=rowd4.createCell(5);
    				String str3=dzw1.get(i).getDcfz();
    				bb1.setCellStyle(style3);
    				bb1.setCellValue(Double.parseDouble(str3));
    				Scord1+=Double.parseDouble(str3);
    				
    				bb1=rowd4.createCell(6);
    				bb1.setCellStyle(style3);
    				bb1.setCellValue(dzw1.get(i).getNeeduserscore());
    				
    				bb1=rowd4.createCell(8);
    				String str4=dzw1.get(i).getGrade();
    				bb1.setCellStyle(style3);
    				if(StringUtil.isNotEmpty(str4)) {
    					bb1.setCellValue(Double.parseDouble(str4));
    					Lastsocrd1+=Double.parseDouble(str4);
    				}
    				
    				
    				for(int j=2;j<=10;j++)
    	    			setBorderForMergeCell(HSSFCellStyle.BORDER_THIN,new CellRangeAddress(num1-dzw1.size()+k1,num1-dzw1.size()+k1,j,j),sheet1,wb);
    				dzw1.remove(i);    	
    				rowd4=sheet1.createRow(num1-dzw1.size()+k1);
    			}
    			else i++;
    		}
    		for(int j=2;j<=10;j++)
    			setBorderForMergeCell(HSSFCellStyle.BORDER_THIN,new CellRangeAddress(num1-dzw1.size()+k1,num1-dzw1.size()+k1,j,j),sheet1,wb);
    		k1++;
    		Peoplemonly+=Peoplemonly1;
    		Chanmuch+=Chanmuch1;
    		Scord+=Scord1;
    		Lastsocrd+=Lastsocrd1;
    		bb1=rowd4.createCell(1);
    		bb1.setCellStyle(style3);
    		bb1.setCellValue("合计");
    		bb1=rowd4.createCell(3);
    		bb1.setCellStyle(style3);
    		bb1.setCellValue(Peoplemonly1);
    		bb1=rowd4.createCell(4);
    		bb1.setCellStyle(style3);
    		bb1.setCellValue(Chanmuch1);
    		bb1=rowd4.createCell(5);
    		bb1.setCellStyle(style3);
    		bb1.setCellValue(Scord1);
    		bb1=rowd4.createCell(8);
    		bb1.setCellStyle(style3);
    		bb1.setCellValue(Lastsocrd1);
    		y1=num1-dzw1.size()+k1-1;
    		sheet1.addMergedRegion(new CellRangeAddress(x,y1,0,0));
    		setBorderForMergeCell(HSSFCellStyle.BORDER_THIN,new CellRangeAddress(x,y1,0,0),sheet1,wb);
    		
    	}
    	rowd4=sheet1.createRow(y1+1);
    	HSSFCell bb1=rowd4.createCell(0);
    	bb1.setCellStyle(style3);
		bb1.setCellValue("合计");
		bb1=rowd4.createCell(3);
    	bb1.setCellStyle(style3);
		bb1.setCellValue(Peoplemonly);
		bb1=rowd4.createCell(4);
    	bb1.setCellStyle(style3);
		bb1.setCellValue(Chanmuch);
		bb1=rowd4.createCell(5);
    	bb1.setCellStyle(style3);
		bb1.setCellValue(Scord);
		bb1=rowd4.createCell(8);
    	bb1.setCellStyle(style3);
		bb1.setCellValue(Lastsocrd);
		sheet1.addMergedRegion(new CellRangeAddress(y1+1,y1+1,0,1));
		setBorderForMergeCell(HSSFCellStyle.BORDER_THIN,new CellRangeAddress(y1+1,y1+1,0,1),sheet1,wb);
		for(int j=2;j<=10;j++)
			setBorderForMergeCell(HSSFCellStyle.BORDER_THIN,new CellRangeAddress(y1+1,y1+1,j-1,j),sheet1,wb);
		
    	
    	sheet1.addMergedRegion(new CellRangeAddress(0,0,0,8));
    	setBorderForMergeCell(HSSFCellStyle.BORDER_THIN,new CellRangeAddress(0,0,0,8),sheet1,wb);
    	sheet1.addMergedRegion(new CellRangeAddress(0,0,9,10));
    	setBorderForMergeCell(HSSFCellStyle.BORDER_THIN,new CellRangeAddress(0,0,9,10),sheet1,wb); 	
    	sheet1.addMergedRegion(new CellRangeAddress(1,1,3,5));
    	setBorderForMergeCell(HSSFCellStyle.BORDER_THIN,new CellRangeAddress(1,1,3,5),sheet1,wb);
    	sheet1.addMergedRegion(new CellRangeAddress(1,1,6,7));
    	setBorderForMergeCell(HSSFCellStyle.BORDER_THIN,new CellRangeAddress(1,1,6,7),sheet1,wb);
    	sheet1.addMergedRegion(new CellRangeAddress(1,1,8,9));
    	setBorderForMergeCell(HSSFCellStyle.BORDER_THIN,new CellRangeAddress(1,1,8,9),sheet1,wb);
    	
    	sheet1.addMergedRegion(new CellRangeAddress(2,3,0,0));
    	setBorderForMergeCell(HSSFCellStyle.BORDER_THIN,new CellRangeAddress(2,3,0,0),sheet1,wb); 	
    	sheet1.addMergedRegion(new CellRangeAddress(2,3,1,1));
    	setBorderForMergeCell(HSSFCellStyle.BORDER_THIN,new CellRangeAddress(2,3,1,1),sheet1,wb);
    	sheet1.addMergedRegion(new CellRangeAddress(2,3,2,2));
    	setBorderForMergeCell(HSSFCellStyle.BORDER_THIN,new CellRangeAddress(2,3,2,2),sheet1,wb);
    	sheet1.addMergedRegion(new CellRangeAddress(2,3,3,3));
    	setBorderForMergeCell(HSSFCellStyle.BORDER_THIN,new CellRangeAddress(2,3,3,3),sheet1,wb);
    	sheet1.addMergedRegion(new CellRangeAddress(2,2,4,5));
    	setBorderForMergeCell(HSSFCellStyle.BORDER_THIN,new CellRangeAddress(2,2,4,5),sheet1,wb); 	
    	sheet1.addMergedRegion(new CellRangeAddress(2,2,6,7));
    	setBorderForMergeCell(HSSFCellStyle.BORDER_THIN,new CellRangeAddress(2,2,6,7),sheet1,wb);
    	sheet1.addMergedRegion(new CellRangeAddress(2,2,8,9));
    	setBorderForMergeCell(HSSFCellStyle.BORDER_THIN,new CellRangeAddress(2,2,8,9),sheet1,wb);
    	sheet1.addMergedRegion(new CellRangeAddress(1,3,10,10));
    	setBorderForMergeCell(HSSFCellStyle.BORDER_THIN,new CellRangeAddress(1,3,10,10),sheet1,wb);
    	
    	
    	for(int i=0;i<=11;i++)
    	{
    		sheet1.autoSizeColumn(i);
    		sheet1.autoSizeColumn(i,true);
    	}
        
    	
    	
    	String fileName="信息查询";
    	ByteArrayOutputStream os=new ByteArrayOutputStream();
    	wb.write(os);
    	byte[] content=os.toByteArray();
    	InputStream is= new ByteArrayInputStream(content);
    	response.reset();
    	response.setContentType("application/vnd.ms-excel;charset=utf-8");
    	response.setHeader("Content-Disposition", "attachment;filename="+new String((fileName+".xls").getBytes(),"iso-8859-1"));
    	ServletOutputStream out=response.getOutputStream();
    	BufferedInputStream bis=null;
    	BufferedOutputStream bos=null;
    	try{
    		bis=new BufferedInputStream(is);
    		bos=new BufferedOutputStream(out);
    		byte[] buff=new byte[2048];
    		int bytesRead;
    		while(-1!=(bytesRead=bis.read(buff, 0, buff.length))){
    			bos.write(buff,0, bytesRead);
    		}
    	}
    	catch(Exception e){
    		e.printStackTrace();
    	}finally{
    		if(bis!=null)
    			bis.close();
    		if(bos!=null)
    			bos.close();
    	}
    	out.print("{\"type\":\"success\"}");
    	out.flush();
    	
    }
}
